package com.example.permission.myjbm.dao;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.example.jbmsuppliers.sinopec.utlis.ExitAppUtlis;
import com.example.jbmsuppliers.sinopec.view.DialogLoading;
import com.example.jbmsuppliers.sinopec.view.DoubleButtonDialog;
import com.jbm.jbmsupplier.util.ICtrl;

/**
 * Created by JBMhaier on 2017/1/17.
 */

public abstract class BaseAty extends AppCompatActivity {
    protected DialogLoading baseLoader;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ExitAppUtlis.getInstance().addActivity(this);
        baseLoader=new DialogLoading(this);
    }
  protected   Handler handlerAty=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            ICtrl obj = (ICtrl)msg.obj;
            if(obj.back==true){
                netHandler(msg.what,msg.obj);
            }else{
                netFial(obj.errorinfo);
            }
            baseLoader.dismiss();
        }
    };
    //hander成功回调返回数据
    protected void netHandler(int what,Object obj){

    }

    //handler返回失败
    protected void netFial(String error){
        hint(error);
    }


    //提示
    public    void hint(String name) {
        final DoubleButtonDialog dialog = new DoubleButtonDialog(
                this, name);
        dialog.getokbtn().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();

            }
        });
        dialog.setisVisibility();

    }
}
